<!--树状下拉-->
<template>
  <el-select
    v-model="value"
    v-bind="$attrs"
    :id="'c' + formItemMeta.columnId"
    :name="'c' + formItemMeta.columnId"
    :clearable="clearable"
    :multiple="multiple"
    :collapse-tags="collapseTags"
    :collapse-tags-tooltip="collapseTagsTooltip"
  >
    <el-option
      v-for="item in optionList"
      :key="'select_' + '_' + item.value"
      :label="'　'.repeat(item.level) + item.label"
      :value="item.value"
      :disabled="item.disabled"
    >
    </el-option>
  </el-select>
</template>

<script lang="ts">
  import { defineComponent, computed } from 'vue'
  // import { ElSelect, ElOption } from 'element-plus'
  // 引入组件需要的属性 引入表单子控件的管理类
  import { itemProps, itemController, loadController } from '../map'

  export default defineComponent({
    name: 'nf-el-from-select-tree',
    inheritAttrs: false,
    components: {
      // ElSelect, ElOption
    },
    props: {
      ...itemProps, // 基础属性
      'collapse-tags': {
        type: Boolean,
        default: true
      },
      'collapse-tags-tooltip': {
        type: Boolean,
        default: true
      },
      colName: String, // 变更字段名称
      modelValue: [String, Number, Array]
    },
    emits: ['update:modelValue'],
    setup (props, context) {
      const multiple = computed (() => props.formItemMeta.controlType === 166)

      // 从后端获取数据
      const { loadDict } = loadController(props)
      loadDict()

      return {
        multiple,
        ...itemController(props, context.emit)
      }
    }
  })
</script>
